
# 钉钉机器人聊天示例
import requests
import json

# url = '您机器人的webhook地址'
url = 'https://oapi.dingtalk.com/robot/send?access_token=73182543ea13fcfee0ea51d5b2f3a19f067bea2a15a06539ffe8761a775253f5'

headers = {
    'Content-Type': 'application/json; charset=UTF-8'
}
# data = {
#     "msgtype": "text",
#     "text": {
#         "content": "我是魏老师！好好学习天天向上我就是我, 是不一样的烟火@156xxxx8827"
#     },
#     "at": {
#         "atMobiles": [  # @哪些人
#             # "156xxxx8827",
#             # "189xxxx8325"
#         ],
#         "isAtAll": False  # @所有人
#     }
# }
# data = {
#     "msgtype": "markdown",
#     "markdown": {
#         "title": "春节放假通知",
#         "text": """## 放假通知
# ![](http://tedu.weimingze.com/static/py_library/_images/202102.jpeg)
# 好好学习天天向上 [TMOOC](http://tmooc.cn)
# """
#     },
#     "at": {
#         "atMobiles": [
#             "13488820215"
#         ],
#         "isAtAll": False
#     }
# }

data = {
    "msgtype": "markdown",
    "markdown": {
        "title": "NSD2105-七夕节",
        "text": """#### 七夕节
> 银烛秋光冷画屏，轻罗小扇扑流萤。天街夜色凉如水，卧看牵牛织女星。
好好学习天天向上 
> ![screenshot](http://tedu.weimingze.com/static/py_library/_images/qixi.jpeg)
> ###### 七夕 [七夕](https://baike.sogou.com/v179909070.htm) 
"""
    },
    "at": {
        "atMobiles": [
        ],
        "isAtAll": False
    }
}


r = requests.post(url, headers=headers, data=json.dumps(data))
print(r.json())
